<!-- List of activieties  -->
        <script type="text/javascript">
        /* <![CDATA[ */ 
        function selectAll(checkbox){
            var inputs = $('activities_list').getElementsByTagName('input');
                if(checkbox.checked){
                    for(i=0;i<inputs.length;i++) inputs[i].checked=true;
                }
                else{
                    for(i=0;i<inputs.length;i++) inputs[i].checked=false;
                }
        }
        /* ]]> */
        </script>

        <% form_tag :controller => 'invoices', :action => 'remove_activities' do -%>
        
        <table class="standard" id="activities_list">
       
        <tr>
            <th> Project</th>
            <th> Person</th>
            <th> Date </th>
            <th> Hours </th>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>

        <% minutes_sum=0 	 
        for activity in @activities  
        minutes_sum+=activity.minutes %>
        <tr>
            <td>					<%= link_to activity.project.name, :controller => 'projects', :action => 'show', :id => activity.project %></td>
            <td>					<%= link_to activity.user.login, :controller => 'users', :action => 'show', :id => activity.user %>				
                (<%= activity.user.role.short_name.upcase %>)</td>
            <td style="text-align: center"><%= h activity.date %></td>
            <td style="text-align: right">					<%= hour_format(activity.minutes) %>				</td>
            <td><%= link_to "Show", :controller => 'activities', :action => "show", :id => activity %></td>
            <td style="text-align:center">
            <%= check_box_tag("activity_id[]", activity.id, false, :id => nil) unless @invoice.is_issued%>
            </td>
            </tr>
        <% end %>
        
        <tr>
            <td colspan="2"></td>
            <th style="text-align: right">Sum:</th>
            <th><%= hour_format(minutes_sum) %></th>
            <td style="text-align:right"></td>
            <td style="text-align:center">
            </td>
        </tr>
        <% unless @invoice.is_issued -%>
        <tr>
            <td colspan="6" style="text-align:right">  
            <%= hidden_field_tag("id", @invoice.id) %>
            Remove from invoice:
            &nbsp;&nbsp; 
            <%= check_box_tag("select_all", 1, false, {:id => nil, :onclick=>"selectAll(this)"}) %>
            select all
            &nbsp;&nbsp;
            <%= submit_tag("Remove", {:onclick => "confirm('Are you sure?')"}) %>
            </td>
        </tr>
        <% end -%>
        </table>
        <% end %> 

<!-- End of list -->

